{include file="header.htm" /}
<body class="bodystyle" style="overflow-y: scroll; cursor: default; -moz-user-select: inherit;">
<div id="toolTipLayer" style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    {include file="bar.htm" /}
    <form class="form-horizontal" id="post_form" action="{:weapp_url('Sample/Sample/edit')}" method="post">
        <div class="ncap-form-default">
            <dl class="row">
                <dt class="tit">
                    <label for="title"><em>*</em>网站名称</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="title" value="{$row.title|default=''}" id="title" class="input-txt">
                    <span class="err"></span>
                    <p class="notic"></p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="url"><em>*</em>网址URL</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="url" placeholder="http://" value="{$row.url|default=''}" id="url" class="input-txt">
                    <span class="err"></span>
                    <p class="notic"></p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="logo"><em>*</em>上传Logo</label>
                </dt>
                <dd class="opt">
                    <div class="input-file-show div_logo_local" {neq name="$row.is_remote" value="0"}style="display: none;"{/neq}>
                        <span class="show">
                            <a id="img_a_local" target="_blank" class="nyroModal" rel="gal" href="{$row.logo_local|default='javascript:void(0);'}">
                                <i id="img_i_local" class="fa fa-picture-o" {notempty name="$row.logo_local"}onmouseover="layer_tips=layer.tips('<img src={$row.logo_local|default=''} class=\'layer_tips_img\'>',this,{tips: [1, '#fff']});"{/notempty} onmouseout="layer.close(layer_tips);"></i>
                            </a>
                        </span>
                        <span class="type-file-box">
                            <input type="text" id="logo_local" name="logo_local" value="{$row.logo_local|default=''}" class="type-file-text" autocomplete="off">
                            <input type="button" name="button" id="button1" value="选择上传..." class="type-file-button">
                            <input class="type-file-file" onClick="GetUploadify(1,'','allimg','img_call_back')" size="30" hidefocus="true" nc_type="change_site_logo"
                                 title="点击前方预览图可查看大图，点击按钮选择文件并提交表单后上传生效">
                        </span>
                    </div>
                    <input type="text" id="logo_remote" name="logo_remote" value="{$row.logo_remote|default=''}" placeholder="http://" class="input-txt" {neq name="$row.is_remote" value="1"}style="display: none;"{/neq}>
                    &nbsp;
                    <label><input type="checkbox" name="is_remote" id="is_remote" value="1" {eq name="$row.is_remote" value="1"}checked="checked"{/eq} onClick="clickRemote(this, 'logo');">远程图片</label>
                    <span class="err"></span>
                    <p class="notic">建议尺寸 88 * 31 (像素) 的gif或jpg文件</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="sort_order">排序</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="sort_order" value="{$row.sort_order|default='100'}" id="sort_order" class="input-txt">
                    <span class="err"></span>
                    <p class="notic">越小越靠前</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="intro">网站备注</label>
                </dt>
                <dd class="opt">
                    <textarea rows="5" cols="80" id="intro" name="intro" style="height:80px;" placeholder="备注一些站长联系方式、信息等内容">{$row.intro|default=''}</textarea>
                    <p class="notic"></p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label>新窗口打开</label>
                </dt>
                <dd class="opt">
                    <div class="onoff">
                        <label for="target1" class="cb-enable {if condition='$row.target eq 1'}selected{/if}">是</label>
                        <label for="target0" class="cb-disable {if condition='$row.target eq 0'}selected{/if}">否</label>
                        <input id="target1" name="target" value="1" type="radio" {if condition="$row.target eq 1"} checked="checked"{/if}>
                        <input id="target0" name="target" value="0" type="radio" {if condition="$row.target eq 0"} checked="checked"{/if}>
                    </div>
                    <p class="notic"></p>
                </dd>
            </dl>
            <div class="bot">
                <input type="hidden" name="id" value="{$row.id}">
                <a href="JavaScript:void(0);" onclick="checkForm();" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">
    // 判断输入框是否为空
    function checkForm(){
        if($('input[name=url]').val() == ''){
            showErrorMsg('网址URL不能为空！');
            $('input[name=url]').focus();
            return false;
        }
        if($('input[name=title]').val() == ''){
            showErrorMsg('网站名称不能为空！');
            $('input[name=title]').focus();
            return false;
        }
        if ($('input[name=typeid]:checked').val() == 2) {
            if ($('input[name=is_remote]').is(':checked')) {
                if($('input[name=logo_remote]').val() == ''){
                    showErrorMsg('请上传网站Logo图片！');
                    $('input[name=logo_remote]').focus();
                    return false;
                }
            } else {
                if($('input[name=logo_local]').val() == ''){
                    showErrorMsg('请上传网站Logo图片！');
                    $('input[name=logo_local]').focus();
                    return false;
                }
            }
        }
        layer_loading('正在处理');
        $('#post_form').submit();
    }
    
    function img_call_back(fileurl_tmp)
    {
        $("#logo_local").val(fileurl_tmp);
        $("#img_a").attr('href', fileurl_tmp);
        $("#img_i").attr('onmouseover', "layer_tips=layer.tips('<img src="+fileurl_tmp+" class=\\'layer_tips_img\\'>',this,{tips: [1, '#fff']});");
    }

    $(function(){
        $('input[name=typeid]').click(function(){
            var val = $(this).val();
            if (val == 2) {
                $('.typeid2').show();
            } else {
                $('.typeid2').hide();
            }
        });
    });
</script>
{include file="footer.htm" /}